package com.djk.daily.thread.sixstates;

/**
 * 描述： 展示线程的New、Runnable、Terminated
 */
public class NewRunnableTerminated implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println(i);
        }
    }

    public static void main(String[] args) {
        Thread thread = new Thread(new NewRunnableTerminated());
        System.out.println("当前线程状态1：" + thread.getState());
        thread.start();
        System.out.println("当前线程状态2：" + thread.getState());

        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //打印出Runnable的状态，即使是正在运行，也是Runnable，而不是Running
        System.out.println("当前线程状态3：" + thread.getState());

        //结束
        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程状态4：" + thread.getState());
    }


}
